﻿<%@ Page Language="C#" EnableViewState="false" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Forum.Web.Admin.Recommend.Default" %>

<%@ Register assembly="Public.Control" namespace="Public.Control" tagprefix="cc1" %>

<html>
<head id="Head1" runat="server">
    <title></title>
<link href="../styles/control.css" type="text/css" rel="stylesheet" />
    <link href="../styles/dntmanager.css" rel="stylesheet" type="text/css" />
        <link href="../styles/modelpopup.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
<!--
#td_l {
	border-right-width: 1px;
	border-left-width: 1px;
	border-right-style: dashed;
	border-left-style: dashed;
	border-right-color: #CCCCCC;
	border-left-color: #CCCCCC;
}
.STYLE1 {color: #FF0000}
-->
    </style>
</head>
<script src="../js/public.js" type="text/javascript"></script>
<script src="../js/common.js" type="text/javascript"></script>
<script src="../js/modalpopup.js" type="text/javascript"></script>
<body  class="ContentBody">
<form id="form2" runat="server">
<cc1:Hint ID="Hint1" runat="server" HintImageUrl="../images" />
<div class="ManagerForm">
		<fieldset>
		    <legend style="background:url(../images/icons/icon25.jpg) no-repeat 6px 50%;">添加/修改分类结构</legend>

        
<div class="MainDiv">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" bordercolordark="#ffffff" bordercolorlight="#cfd3de">
   <tr>
		 <td valign="top" style="padding:5px; width:300px" id="td_yc">
             <table border="0" cellpadding="0" cellspacing="0" width="100%" height="100%">
                 <tr>
                     <td style="height: 20px;">
                         <strong>分类结构图</strong></td>
                 </tr>
                 <tr>
                     <td  valign="top" >
                         <iframe id='if1' src="list.aspx" frameborder=0 width=100% height=100% scrolling=auto ></iframe></td>
                 </tr>
           </table>
         </td>
         <td height="460"
             valign="middle" id="td_l" style="padding-right: 3px; padding-left: 3px; cursor: hand; width: 5px;" onClick="yc();">
                 <img border="0" id='jiao' src="../images/BttnLeft.gif" width="9" height="16" /></td>
  <td valign="top" style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px; padding-top: 5px">
             <table border="0" bordercolordark="#ffffff" bordercolorlight="#cfd3de" cellpadding="0"
                 cellspacing="0" style="width: 100%" height="100%">
    <tr>
                     <td style="padding-left: 5px; font-weight: bold; height: 25px">
                         <span id='sp1'><img align="absMiddle" border="0" src="../images/add.gif" width="16" height="16" />
                             添加新分类到指定分类下</span><span id='sp2' style="display:none;"><img
                             align="absMiddle" src="../images/icon_edit.gif" width="16" height="16" />
                             编辑所选择的分类</span></td>
               </tr>
                 <tr>
                     <td valign="top" style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px; padding-top: 5px">
                   <table border="0" cellpadding="0" cellspacing="0" 
                             style="width: 100%; padding-right: 5px;">
<tr>
                                 <td height="40" align="right" style="padding-right: 5px"><strong>
                                   分类名称:</strong></td>
<td>
                                      &nbsp;
<cc1:TextBox ID="Text1" HintInfo="英文汉字均可,不能为空" runat="server" Width="210px" HintShowType="down"></cc1:TextBox>
                    <span style="display:none;"><input id="Text2" style="width: 12px" type="text" /></span></td>
                     </tr>
                             <tr>
                                 <td height="40" align="right" style="padding-right: 5px; width:100px"><strong>
                                     对应分类:</strong></td>
                               <td>
		 &nbsp;                        <select id="f_mululist0" runat="server"></select>                                     </td>
                     </tr>
                             <tr>
                                 <td height="40" align="right" style="padding-right: 5px"><strong>
                                   分类说明:</strong></td>
<td>
                                      &nbsp;
                        <cc1:TextBox 
                                          ID="TextArea1" HintInfo="简单的说明" runat="server" Width="300px" Height="80px" 
                                          TextMode="MultiLine"></cc1:TextBox></td>
                     </tr>
                             <tr>
                                 <td height="40">&nbsp; </td>
                               <td height="50">
                                 <span id='sp3'>
<cc1:Button ID="Button4" runat="server" AutoPostBack="False" 
                                       ButtonImgUrl="../images/add.gif" Text=" 添 加" ValidateForm="False" 
                                       ScriptContent="return Button1_onclick()" /></span>&nbsp;<span id='sp4' style="display:none;"><cc1:Button ID="Button1" runat="server" AutoPostBack="False" 
                                       ButtonImgUrl="../images/icon_edit.gif" Text=" 修 改" ValidateForm="False" 
                                       ScriptContent="return Button2_onclick()" /></span></td>
                     </tr>
                       </table>                   </td>
                 </tr>
           </table>
	    </td>
	 </tr>
	</table>    
</div>
		</fieldset>
        <div class="Navbutton" style="display:none;">
        </div>
        </div>
    </form>
<script type="text/javascript">
      function ctl(a__) {
          return document.getElementById(a__);
      }
      function yc() {
          var td_yc = ctl('td_yc');
          var jiao = ctl('jiao');

          if (td_yc.style.display == '') {
              td_yc.style.display = 'none';
              jiao.src = '../images/BttnRight.gif';
          }
          else {
              td_yc.style.display = '';
              jiao.src = '../images/BttnLeft.gif';
          }
      }

      //设置要添加的组的父ID
      function add_data(b__) {
          var Text2 = ctl('Text2');
          Text2.value = b__;

          ctl('sp1').style.display = '';
          ctl('sp2').style.display = 'none';
          ctl('sp3').style.display = '';
          ctl('sp4').style.display = 'none';

          ctl('Text1').value = '';
          ctl('TextArea1').value = '';
      }


      function edit_data(id_) {

          editshow(id_);
      }
      function editshow(id_) {
          hbctl_.$("f_mululist0").selectedIndex = 0;
          var rtxt = Forum.Web.Admin.Recommend.Default.getmodel(id_).value;

          ctl('Text2').value = id_;
          ctl('Text1').value = rtxt.Rd_Name;
          ctl('TextArea1').value = rtxt.Rd_Description;

          ctl('sp1').style.display = 'none';
          ctl('sp2').style.display = '';
          ctl('sp3').style.display = 'none';
          ctl('sp4').style.display = '';

          for (var i = 0; i < hbctl_.$("f_mululist0").length; i++) {
              if (hbctl_.$("f_mululist0").options[i].value == rtxt.Rd_MuLuID) {
                  hbctl_.$("f_mululist0").selectedIndex = i;
                  break;
              }
          }
      }
      function Button1_onclick() {
          if (ctl('Text1').value.length > 1) {
              if (ctl('Text2').value.length > 0) {
                  addv();
              }
              else {
                  alert('请在左边的栏目结构树上选择一项要添加下级的栏目！');
              }
          }
          else {
              alert('请输入新栏目名称!');
          }
      }

      function addv() {
          var rtxt = Forum.Web.Admin.Recommend.Default.Add(ctl('Text2').value, ctl('Text1').value, ctl('TextArea1').value, hbctl_.GetValueOrTextBySelectID("f_mululist0", "value")).value;
          if (rtxt == '1') {
              alert('添加成功！');

              var i = Math.round(Math.random() * 100); //生成0-50之前的随机数
              var if1 = ctl('if1');
              if1.src = 'List.aspx?key=' + i;
          }
          else {
              alert('对不起，操作失败，请稍候再试！');
          }
      }
      function Button2_onclick() {
          if (ctl('Text1').value.length > 1) {
              if (ctl('Text2').value.length > 0) {
                  edit();
              }
              else {
                  alert('请在左边的栏目结构树上选择一项要添加下级的栏目！');
              }
          }
          else {
              alert('请输入新栏目名称!');
          }
      }

      function edit() {
          //alert("ID:"+ctl('Text2').value+"\n 标题"+ctl('Text1').value+"\n 说明"+ctl('TextArea1').value+"\n 版主"+ctl('f_baizhu').value+"\n 排序"+ctl('f_paixu').value+"\n 图片"+ctl('f_tu').value+"\n 颜色"+hbctl_.GetValueOrTextBySelectID("title_color","value")+"\n 分类"+hbctl_.GetValueOrTextBySelectID("fu_fllist","value"));

          var rtxt = Forum.Web.Admin.Recommend.Default.edit_(ctl('Text2').value, ctl('Text1').value, ctl('TextArea1').value, hbctl_.GetValueOrTextBySelectID("f_mululist0", "value")).value;
          if (rtxt == '1') {
              alert('修改成功！');

              var i = Math.round(Math.random() * 100); //生成0-50之前的随机数
              var if1 = ctl('if1');
              if1.src = 'List.aspx?key=' + i;
          }
          else {
              alert('对不起，操作失败，请稍候再试！');
          }
      }
      </script>
</body>
</html>